import {
    pkFetch
} from './pkFetch'
const userServer = `${window.config.server}`
export default {
    // ---------------------登陆接口----------------------
    //登陆
    login(loginObj) {
        return pkFetch.post(`${userServer}/login`, loginObj)
    },
    //退出登陆
    loginOut() {
        return pkFetch.get(`${userServer}/logout`)
    },
    // ---------------------用户接口----------------------
    getUserList(searchObj) {
        return pkFetch.get(`${userServer}/user`, searchObj)
    },
    // ---------------------分类接口----------------------
    //获取分类列表
    getCategoryList() {
        return pkFetch.get(`${userServer}/category`)
    },
    //新增一级分类
    addTopCategory(cateObj) {
        return pkFetch.post(`${userServer}/category`, cateObj)
    },
    //新增二级分类
    addSecondCategory(id, cateObj) {
        return pkFetch.post(`${userServer}/category/` + id + `/child`, cateObj)
    },
    //修改分类
    editCategory(id, cateObj) {
        return pkFetch.put(`${userServer}/category/` + id, cateObj)
    },
    //删除分类
    delTopCategory(id) {
        return pkFetch.delete(`${userServer}/category/` + id)
    },
    //删除子分类
    delSecondCategory(parentId, id) {
        return pkFetch.delete(`${userServer}/category/` + parentId + `/child/` + id)
    },
    //获取子分类下的题目数量
    getCategoryInfo(id) {
        return pkFetch.get(`${userServer}/category/` + id + `/type`)
    },

    // --------------------题库接口----------------------
    //获取题库列表
    getQuestionList(searchObj) {
        return pkFetch.get(`${userServer}/question`, searchObj)
    },
    //通过分类查询
    getQuestionListByCategory(id, searchObj) {
        return pkFetch.get(`${userServer}/category/` + id + `/question`, searchObj)
    },
    //通过分类名称查询
    getQuestionListByCategoryName(name, searchObj) {
        return pkFetch.get(`${userServer}/categoryinfo/` + name + `/question`, searchObj)
    },
    //新增题库
    addQuestion(questionObj) {
        return pkFetch.post(`${userServer}/question/add`, questionObj)
    },
    //编辑题库
    editQuestion(id, questionObj) {
        return pkFetch.put(`${userServer}/question/edit/` + id, questionObj)
    },
    //删除题库
    delQuestion(id) {
        return pkFetch.delete(`${userServer}/question/del/` + id)
    },
    //查询标题
    getQuestionListByTitle(title, searchObj) {
        return pkFetch.get(`${userServer}/title/` + title + `/question`, searchObj)
    },
    //通过题目类型查找
    getQuetionListByType(type, category, searchObj) {
        return pkFetch.get(`${userServer}/type/` + type + `/category/` + category + `/question`, searchObj)
    },
    //查找分类下有那种类型的题目
    getTypeByCategory(category) {
        return pkFetch.get(`${userServer}/category/` + category + `/type`)
    },

    // --------------------考试接口----------------------
    //获取考试列表
    getExamList(searchObj) {
        return pkFetch.get(`${userServer}/paper_setting`, searchObj)
    },
    //新增考试
    addExam(examObj) {
        return pkFetch.post(`${userServer}/paper_setting`, examObj)
    },
    //编辑考试
    editExam(id, examObj) {
        return pkFetch.put(`${userServer}/paper_setting/` + id, examObj)
    },
    //删除隐藏考试
    delDisExam(id, delSet) {
        return pkFetch.put(`${userServer}/paper_setting/del/` + id, delSet)
    },
    //获取任务列表
    getTaskList(id) {
        return pkFetch.get(`${userServer}/paper_setting/` + id + `/paper_task`)
    },
    //新增任务
    addTask(id, taskObj) {
        return pkFetch.post(`${userServer}/paper_setting/` + id + `/paper_task`, taskObj)
    },
    //编辑任务
    editTask(id, taskObj) {
        return pkFetch.put(`${userServer}/paper_task/` + id, taskObj)
    },
    //删除任务
    delTask(set_id, id) {
        return pkFetch.delete(`${userServer}/paper_setting/` + set_id + `/paper_task/` + id)
    },
    //删除隐藏任务
    delDisTask(id, delTask) {
        return pkFetch.put(`${userServer}/paper_task/del/` + id, delTask)
    },
    //获取二维码
    getQrcode(set_id, id) {
        return pkFetch.post(`${userServer}/paper_setting/` + set_id + `/paper_task/` + id + `/qrcode`)
    },
    //获取成绩二维码
    getScorecode(set_id, id) {
        return pkFetch.post(`${userServer}/paper_task/` + id + `/scoreCode`)
    },
    //获取试卷列表
    getPaperList(task, searchObj) {
        return pkFetch.get(`${userServer}/paper_task/` + task + `/paper`, searchObj)
    },
    //查看试卷
    getPaperDetail(paperId, searchObj) {
        return pkFetch.get(`${userServer}/paper/` + paperId + `/paper_answer`, searchObj)
    },
    //查看试卷
    getPaperAnalyze(paperId) {
        return pkFetch.get(`${userServer}/paper/` + paperId + `/paper_analyze`)
    },
    //查找用户试卷
    getPaperByName(task, name, searchObj) {
        return pkFetch.get(`${userServer}/paper_task/` + task + `/paper/` + name, searchObj)
    },
    //获取公司列表
    getCompanyList() {
        return pkFetch.get(`${userServer}/company`)
    },
    //新增城市
    addCompany(companyObj) {
        return pkFetch.post(`${userServer}/company`, companyObj)
    },
    //编辑城市
    editCompany(companyId, companyObj) {
        return pkFetch.put(`${userServer}/company/` + companyId, companyObj)
    },
    //删除城市
    delCompany(companyId) {
        return pkFetch.delete(`${userServer}/company/` + companyId)
    },
    // 刷新试卷个数
    upPaperAnswerNum(taskId) {
        return pkFetch.get(`${userServer}/upPaper/` + taskId)
    }
}